package com.oauth.global.client.ui.birthday;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.oauth.components.client.ui.HorizontalFlowPanel;
import com.oauth.global.client.beans.BirthdayClientBean;

public class BirthdayPanel extends Composite {

	private int count = 0;

	private static BirthdayPanelUiBinder uiBinder = GWT.create(BirthdayPanelUiBinder.class);

	interface BirthdayPanelUiBinder extends UiBinder<Widget, BirthdayPanel> {
	}

	@UiField
	HorizontalFlowPanel memberPanel;

	@UiField
	Label dayText;

	@UiField
	Label countText;

	public BirthdayPanel() {
		initWidget(uiBinder.createAndBindUi(this));
		setCount(0);
	}

	public void addMember(BirthdayClientBean pBirthday) {
		memberPanel.add(new BirthdayMember(pBirthday));
		setCount(++count);
	}

	public void clear() {
		memberPanel.clear();
		setCount(0);
	}

	public void setDayText(String pText) {
		dayText.setText(pText);
	}

	private void setCount(int count) {
		this.count = count;
		countText.setText("(" + this.count + ")");
	}

	public int getCount() {
		return count;
	}
	/*
	 * public void initBirthdays() { deckPanel.showWidget(0);
	 * service.getUpcomingBirthdays(appInfoBean.getId(), new
	 * OAuthAsnyCallBack<List<BirthdayClientBean>>() {
	 * 
	 * @Override public void onSuccess(List<BirthdayClientBean> pbirthdayList) {
	 * if (pbirthdayList == null || pbirthdayList.isEmpty()) {
	 * memberPanel.add(new HTML("No upcoming birthday's")); } else { for
	 * (BirthdayClientBean birthday : pbirthdayList) { memberPanel.add(new
	 * Birthday(birthday)); } } deckPanel.showWidget(1); } }); }
	 */
}
